<%-- 
    Document   : ModificarSubtipo
    Created on : 29-jun-2008, 20:59:13
    Author     : Ramon
--%>

<%@ page language="java" import="java.util.*" %>
<%@ page language="java" import="java.sql.*" %>
<%@ page language="java" import="com.akcess.vo.*" %>
<%@ page language="java" import="manejadores.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
            String path = request.getContextPath();
            String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>
    <!--  Version: Multiflex-3.12 / Overview                    --><!--  Date:    January 20, 2008                             --><!--  Design:  www.1234.info                                --><!--  License: Fully open source without restrictions.      --><!--           Please keep footer credits with the words    --><!--           "Design by 1234.info" Thank you!             -->


   
    <meta name="description" content="Your page description here ...">
    <meta name="keywords" content="Your keywords, keywords, keywords, here ...">
    <base href="<%=basePath%>">
    <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout4_setup.css">
    <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout4_text.css">
<link rel="icon" type="image/x-icon" href="./img/favicon.ico"><title>SRR - Sistema de Reserva de Recursos</title><!-- Global IE fix to avoid layout crash when single word size wider than column width --><!--[if IE]><style type="text/css"> body {word-wrap: break-word;}</style><![endif]--><link href="./css/highlighter.css" type="text/css" rel="stylesheet"><link href="./css/highlighter_002.css" type="text/css" rel="stylesheet"></head><body>
<!-- Main Page Container -->
<div class="page-container">
    
    <!-- For alternative headers START PASTE here -->

    <!-- A. HEADER -->      
           <jsp:include page="../Header.jsp"/>
            
            <!-- For alternative headers END PASTE here -->

    <!-- B. MAIN -->
    <div class="main">
        
        <!-- B.1 MAIN NAVIGATION -->
        <jsp:include page="../barraOperaciones.jsp"/> 
        
        <!-- B.2 MAIN CONTENT -->
        <div class="main-content">
            
            <!-- Pagetitle -->
            <%
            out.println("<h1 class=\"pagetitle\">Modificar Tipo " + request.getParameter("nombreSubtipo") + "</h1>");
                    %>
                    
            <%
            int idTipo = Integer.parseInt(request.getParameter("id"));
            out.println("<form name=\"crear\" action=\"GestionarTipos_de_Recursos?hacer=modificacion&id=" + idTipo + "\" method=\"post\">");
            Connection cone;
            cone = (Connection) session.getAttribute("conexion");
            ManejadorSubtiposRecursos manejadorTipo = new ManejadorSubtiposRecursos(cone);
            Atributos_recursos[] AtributosDeTipo = manejadorTipo.BuscarAtributosDeTipo(idTipo);
            
            Tipo_recurso tp=manejadorTipo.ObtenerTipo(idTipo);
            
            ManejadorAtributos manejadorAtribu= new ManejadorAtributos(cone);
            Atributos_recursos[] todosAtributos = manejadorAtribu.BuscarTodosAtributos();
            
                out.println("<table border=\"1\">");
                 out.println("<tbody>");
                        out.println("<tr>");
                        out.println("<th class=\"top\">" + "Nombre" + "</td>");
                        out.println("<td><input type=\"text\" name=\"nombreSubtipo\" value=\""+tp.getNombre()+"\"></td>");
                        out.println("</tr>");
                        out.println("<tr>");
                        out.println("<th class=\"top\">" + "Descripcion" + "</th>");
                        out.println("<td><textarea name=\"" + "descripcion"+ "\" cols=\"15\" rows=\"5\" >"+tp.getDescripcion()+"</textarea></td>");
                        out.println("</tr>");
                        out.println("<tr>");
                        out.println("<td>" + "Atributos" + "</td>");
                        out.println("<td>");
                        boolean esta;
                        for (int i=0;i< todosAtributos.length; i++)
                        {
                        esta=false;
                        for (int j = 0;  j < AtributosDeTipo.length; j++) 
                        {
                            if(AtributosDeTipo[j].getNombre().equalsIgnoreCase(todosAtributos[i].getNombre()))
                            {
                                out.println("<input type=\"checkbox\" name=\"" + AtributosDeTipo[j].getNombre() + "\" value=\"true\" checked >" + AtributosDeTipo[j].getNombre());
                                out.println("<br>");
                                esta=true;
                                break;
                            }
                        
                        }
                        if(!esta){
                                out.println("<input type=\"checkbox\" name=\"" + todosAtributos[i].getNombre() + "\" value=\"true\">" + todosAtributos[i].getNombre() );
                                out.println("<br>");
                            }            
                    
                        }
                        out.println("</td>");
                        out.println("</tr>");
                    out.println("</tbody>");
                out.println("</table>");
                
            %>       
            </tbody>
            </table>            
            <table>
                <tbody>
                    <tr>
                        <td>
                            <input type="submit" name="btnGuardar" value="Guardar">
                            <input type="button" name="btnCancelar" value="Cancelar" onclick="location.href = 'GestionarTipos_de_Recursos?hacer=Modificar'">
                        </td>
                    </tr>
                </tbody>
            </table>
            </form>            
        </div>        
        <!-- B.3 SUBCONTENT -->        
    </div>    
    <!-- C. FOOTER AREA -->   
    <%@include file="../footer.jsp"%>     
</div> 
</body>
</html>
